#include "dialog_msbox.h"
#include "ui_dialog_msbox.h"

#define  info "border-image: url(:/info.png);"
#define  err  "border-image: url(:/err.png);"
#define  war  "border-image: url(:/war.png);"

Dialog_msbox::Dialog_msbox(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog_msbox)
{
    ui->setupUi(this);
    this->setWindowFlags(Qt::FramelessWindowHint);

    ui->textEdit->setReadOnly(true);
    txt1=ui->txt1;
    txt2=ui->txt2;
    txt_edit=ui->textEdit;

    t_btn_yes=ui->btn_yes;
    t_btn_no=ui->btn_no;
    t_btn_true=ui->btn_true;


    t_wt_ico=ui->wt_ico;

    connect(ui->btn_no,&QPushButton::clicked,[=]{done(ENM_no_BTN);});
    connect(ui->btn_yes,&QPushButton::clicked,[=]{done(ENM_yes_BTN);});
    connect(ui->btn_true,&QPushButton::clicked,[=]{done(ENM_true_BTN);});

}

Dialog_msbox::~Dialog_msbox()
{
    delete ui;
}
int Dialog_msbox::show(int type,int btn,QString txt1,QString txt2,QString txt_edit,QWidget *parent )
{
    Dialog_msbox box;

    if(type==0)
        box.t_wt_ico->setStyleSheet(info);
    else if(type==1)
        box.t_wt_ico->setStyleSheet(war);
    else if(type==2)
        box.t_wt_ico->setStyleSheet(err);
    else
         box.t_wt_ico->setStyleSheet(info);

    box.txt1->setText(txt1);
    box.txt2->setText(txt2);
    box.txt_edit->append(txt_edit);

    if(btn==0)
    {
        box.t_btn_yes->setHidden(true);
        box.t_btn_no->setHidden(true);
        box.t_btn_true->setHidden(false);

    }else if(btn==1)
    {
        box.t_btn_yes->setHidden(false);
        box.t_btn_no->setHidden(false);
        box.t_btn_true->setHidden(true);
    }

    return box.exec();
}
